package com.xiaobing.common.entity.system;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xiaobing.common.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 用户对象 sys_user
 *
 * @author xulk
 */

@Data
@TableName("sys_user")
@Schema(name = "SysUser", description = "用户对象")
@NoArgsConstructor
@AllArgsConstructor
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;



    /**
     * 用户账号
     */ 
    private String userName;

    /**
     * 用户昵称
     */
   //  @Excel(name = "用户名称")
    private String nickName;

    /**
     * 用户邮箱
     */
   //  @Excel(name = "用户邮箱")
    private String email;

    /**
     * 手机号码
     */
   //  @Excel(name = "手机号码", cellType = ColumnType.TEXT)
    private String phonenumber;

    /**
     * 用户性别
     */
   //  @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /**
     * 用户头像
     */
    private String avatar;

    /**
     * 密码
     */
    private String password;

    /**
     * 帐号状态（0正常 1停用）
     */
   //  @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    private String status;

    /**
     * 角色对象
     */
    @TableField(exist = false)
    private List<SysRole> roles;

    /**
     * 角色组
     */
    @TableField(exist = false)
    private Long[] roleIds;


    public boolean isAdmin() {
        return isAdmin(super.getId());
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 1L == userId;
    }


}
